package com.quaidi.smartlocker.util;

import java.util.Random;

/**
 * 取件码生成工具类
 * 
 * @author QuaiDi
 * @since 2025-08-26
 */
public class PickupCodeUtil {

    private static final Random RANDOM = new Random();

    /**
     * 生成6位数字取件码
     * 
     * @return 6位数字取件码
     */
    public static String generatePickupCode() {
        // 生成100000到999999之间的随机数
        int code = RANDOM.nextInt(900000) + 100000;
        return String.valueOf(code);
    }

    /**
     * 验证取件码格式
     * 
     * @param pickupCode 取件码
     * @return 是否有效
     */
    public static boolean isValidPickupCode(String pickupCode) {
        return pickupCode != null && pickupCode.matches("\\d{6}");
    }
}